<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="pg" uri="http://jsptags.com/tags/navigation/pager"%>
<pg:pager url="${param.url}" items="${pageModel.total}" export="currentPageNumber=pageNumber"
    maxPageItems="${pageModel.pageSize}">
    <pg:first>
        <a href="javascript:void(0)" onclick="changePage('${pageModel.pageSize*(pageNumber-1) }')">首页</a>
    </pg:first>
    <pg:prev>
        <a href="javascript:void(0)" onclick="changePage('${pageModel.pageSize*(pageNumber-1) }')">上一页</a>
        <%-- <a href="${pageUrl }">上一页</a> --%>
    </pg:prev>
    <pg:pages>
        <c:choose>
            <c:when test="${currentPageNumber eq pageNumber}">
                <font color="red">${pageNumber }</font>
            </c:when>
            <c:otherwise>
                <%--  <a href="${pageUrl }">${pageNumber }</a> --%>
                <a href="javascript:void(0)" onclick="changePage('${pageModel.pageSize*(pageNumber-1) }')">
                    ${pageNumber } </a>
            </c:otherwise>
        </c:choose>
    </pg:pages>
    <pg:next>
        <%-- <a href="${pageUrl }">下一页</a> --%>
        <a href="javascript:void(0)" onclick="changePage('${pageModel.pageSize*(pageNumber-1) }')">下一页</a>
    </pg:next>
    <pg:last>
        <%-- <a href="${pageUrl }">尾页</a> --%>
        <a href="javascript:void(0)" onclick="changePage('${pageModel.pageSize*(pageNumber-1) }')">尾页</a>
    </pg:last>
    每页${pageModel.pageSize}件，总共${pageModel.total}件
</pg:pager>
<script type="text/javascript">
	var action = $("form").attr("action");
	var queryform = $("<form id='_query_form' action='" + action + "' method='post'></form>");
	$(":text").each(function() {
		var name = $(this).attr("name");
		var value = $(this).attr("value");
		var hidden = $("<input type='hidden' name='" +name+ "' value='" + value+"' >");
		queryform.append(hidden);
	});
	$("body").append(queryform);

	function changePage(offset) {
		queryform.append($("<input type='hidden' name='offset' value='" + offset + "'>"));
		queryform.submit();
	}
</script>